﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using PAT.Entities;
using PAT.Data;

#endregion

namespace PAT.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="PatKitProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class PatKitProviderBaseCore : EntityProviderBase<PAT.Entities.PatKit, PAT.Entities.PatKitKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByIdItemInventarioFromPatKitItem
		
		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_KIT_ITEM table. Table PAT_KIT is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_KIT_ITEM table.
		/// </summary>
		/// <param name="_idItemInventario"></param>
		/// <returns>Returns a typed collection of PatKit objects.</returns>
		public TList<PatKit> GetByIdItemInventarioFromPatKitItem(System.Int32 _idItemInventario)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatKitItem(null,_idItemInventario, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatKit objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_KIT_ITEM table. Table PAT_KIT is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_KIT_ITEM table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public TList<PatKit> GetByIdItemInventarioFromPatKitItem(System.Int32 _idItemInventario, int start, int pageLength)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatKitItem(null, _idItemInventario, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_KIT_ITEM table. Table PAT_KIT is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_KIT_ITEM table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdItemInventarioFromPatKitItem(TransactionManager transactionManager, System.Int32 _idItemInventario)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatKitItem(transactionManager, _idItemInventario, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_KIT_ITEM table. Table PAT_KIT is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_KIT_ITEM table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemInventario"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdItemInventarioFromPatKitItem(TransactionManager transactionManager, System.Int32 _idItemInventario,int start, int pageLength)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatKitItem(transactionManager, _idItemInventario, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_KIT_ITEM table. Table PAT_KIT is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_KIT_ITEM table.
		/// </summary>
		/// <param name="_idItemInventario"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdItemInventarioFromPatKitItem(System.Int32 _idItemInventario,int start, int pageLength, out int count)
		{
			
			return GetByIdItemInventarioFromPatKitItem(null, _idItemInventario, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_KIT_ITEM table. Table PAT_KIT is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_KIT_ITEM table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public abstract TList<PatKit> GetByIdItemInventarioFromPatKitItem(TransactionManager transactionManager,System.Int32 _idItemInventario, int start, int pageLength, out int count);
		
		#endregion GetByIdItemInventarioFromPatKitItem
		
		#region GetByIdOperacionFromPatKitOperacion
		
		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_OPERACION in the
		///		PAT_KIT_OPERACION table. Table PAT_KIT is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_KIT_OPERACION table.
		/// </summary>
		/// <param name="_idOperacion"></param>
		/// <returns>Returns a typed collection of PatKit objects.</returns>
		public TList<PatKit> GetByIdOperacionFromPatKitOperacion(System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdOperacionFromPatKitOperacion(null,_idOperacion, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatKit objects from the datasource by ID_OPERACION in the
		///		PAT_KIT_OPERACION table. Table PAT_KIT is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_KIT_OPERACION table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public TList<PatKit> GetByIdOperacionFromPatKitOperacion(System.Int32 _idOperacion, int start, int pageLength)
		{
			int count = -1;
			return GetByIdOperacionFromPatKitOperacion(null, _idOperacion, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_OPERACION in the
		///		PAT_KIT_OPERACION table. Table PAT_KIT is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_KIT_OPERACION table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdOperacionFromPatKitOperacion(TransactionManager transactionManager, System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdOperacionFromPatKitOperacion(transactionManager, _idOperacion, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_OPERACION in the
		///		PAT_KIT_OPERACION table. Table PAT_KIT is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_KIT_OPERACION table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdOperacionFromPatKitOperacion(TransactionManager transactionManager, System.Int32 _idOperacion,int start, int pageLength)
		{
			int count = -1;
			return GetByIdOperacionFromPatKitOperacion(transactionManager, _idOperacion, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_OPERACION in the
		///		PAT_KIT_OPERACION table. Table PAT_KIT is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_KIT_OPERACION table.
		/// </summary>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdOperacionFromPatKitOperacion(System.Int32 _idOperacion,int start, int pageLength, out int count)
		{
			
			return GetByIdOperacionFromPatKitOperacion(null, _idOperacion, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_OPERACION in the
		///		PAT_KIT_OPERACION table. Table PAT_KIT is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_KIT_OPERACION table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public abstract TList<PatKit> GetByIdOperacionFromPatKitOperacion(TransactionManager transactionManager,System.Int32 _idOperacion, int start, int pageLength, out int count);
		
		#endregion GetByIdOperacionFromPatKitOperacion
		
		#region GetByIdGrupoCatalogoFromPatMantenimientoProgramado
		
		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_GRUPO_CATALOGO in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_KIT is related to table PAT_GRUPO_CATALOGO
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <returns>Returns a typed collection of PatKit objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogoFromPatMantenimientoProgramado(System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogoFromPatMantenimientoProgramado(null,_idGrupoCatalogo, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatKit objects from the datasource by ID_GRUPO_CATALOGO in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_KIT is related to table PAT_GRUPO_CATALOGO
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogoFromPatMantenimientoProgramado(System.Int16 _idGrupoCatalogo, int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogoFromPatMantenimientoProgramado(null, _idGrupoCatalogo, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_GRUPO_CATALOGO in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_KIT is related to table PAT_GRUPO_CATALOGO
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogoFromPatMantenimientoProgramado(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogoFromPatMantenimientoProgramado(transactionManager, _idGrupoCatalogo, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_GRUPO_CATALOGO in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_KIT is related to table PAT_GRUPO_CATALOGO
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogoFromPatMantenimientoProgramado(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo,int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogoFromPatMantenimientoProgramado(transactionManager, _idGrupoCatalogo, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_GRUPO_CATALOGO in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_KIT is related to table PAT_GRUPO_CATALOGO
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogoFromPatMantenimientoProgramado(System.Int16 _idGrupoCatalogo,int start, int pageLength, out int count)
		{
			
			return GetByIdGrupoCatalogoFromPatMantenimientoProgramado(null, _idGrupoCatalogo, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_GRUPO_CATALOGO in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_KIT is related to table PAT_GRUPO_CATALOGO
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public abstract TList<PatKit> GetByIdGrupoCatalogoFromPatMantenimientoProgramado(TransactionManager transactionManager,System.Int16 _idGrupoCatalogo, int start, int pageLength, out int count);
		
		#endregion GetByIdGrupoCatalogoFromPatMantenimientoProgramado
		
		#region GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit
		
		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_DOCUMENTO in the
		///		PAT_ORDEN_TRABAJO_KIT table. Table PAT_KIT is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_KIT table.
		/// </summary>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroOrden"></param>
		/// <returns>Returns a typed collection of PatKit objects.</returns>
		public TList<PatKit> GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(System.Int32 _idDocumento, System.Int32 _numeroOrden)
		{
			int count = -1;
			return GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(null,_idDocumento, _numeroOrden, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatKit objects from the datasource by ID_DOCUMENTO in the
		///		PAT_ORDEN_TRABAJO_KIT table. Table PAT_KIT is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_KIT table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroOrden"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public TList<PatKit> GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(System.Int32 _idDocumento, System.Int32 _numeroOrden, int start, int pageLength)
		{
			int count = -1;
			return GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(null, _idDocumento, _numeroOrden, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_DOCUMENTO in the
		///		PAT_ORDEN_TRABAJO_KIT table. Table PAT_KIT is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_KIT table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroOrden"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(TransactionManager transactionManager, System.Int32 _idDocumento, System.Int32 _numeroOrden)
		{
			int count = -1;
			return GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(transactionManager, _idDocumento, _numeroOrden, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_DOCUMENTO in the
		///		PAT_ORDEN_TRABAJO_KIT table. Table PAT_KIT is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_KIT table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroOrden"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(TransactionManager transactionManager, System.Int32 _idDocumento, System.Int32 _numeroOrden,int start, int pageLength)
		{
			int count = -1;
			return GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(transactionManager, _idDocumento, _numeroOrden, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatKit objects from the datasource by ID_DOCUMENTO in the
		///		PAT_ORDEN_TRABAJO_KIT table. Table PAT_KIT is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_KIT table.
		/// </summary>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroOrden"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_KIT objects.</returns>
		public TList<PatKit> GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(System.Int32 _idDocumento, System.Int32 _numeroOrden,int start, int pageLength, out int count)
		{
			
			return GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(null, _idDocumento, _numeroOrden, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_KIT objects from the datasource by ID_DOCUMENTO in the
		///		PAT_ORDEN_TRABAJO_KIT table. Table PAT_KIT is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_KIT table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroOrden"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatKit objects.</returns>
		public abstract TList<PatKit> GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit(TransactionManager transactionManager,System.Int32 _idDocumento, System.Int32 _numeroOrden, int start, int pageLength, out int count);
		
		#endregion GetByIdDocumentoNumeroOrdenFromPatOrdenTrabajoKit
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, PAT.Entities.PatKitKey key)
		{
			return Delete(transactionManager, key.IdKit);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_idKit">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _idKit)
		{
			return Delete(null, _idKit);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idKit">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _idKit);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_PKIT_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(_idGrupoCatalogo, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_PKIT_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		/// <remarks></remarks>
		public TList<PatKit> GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(transactionManager, _idGrupoCatalogo, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_PKIT_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(transactionManager, _idGrupoCatalogo, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_GRUPO_CATALOGO key.
		///		fkPatPkitPatGrupoCatalogo Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdGrupoCatalogo(null, _idGrupoCatalogo, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_GRUPO_CATALOGO key.
		///		fkPatPkitPatGrupoCatalogo Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo, int start, int pageLength,out int count)
		{
			return GetByIdGrupoCatalogo(null, _idGrupoCatalogo, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_PKIT_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public abstract TList<PatKit> GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER key.
		///		FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER Description: 
		/// </summary>
		/// <param name="_idListaPrecios"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdListaPrecios(System.Int32 _idListaPrecios)
		{
			int count = -1;
			return GetByIdListaPrecios(_idListaPrecios, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER key.
		///		FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idListaPrecios"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		/// <remarks></remarks>
		public TList<PatKit> GetByIdListaPrecios(TransactionManager transactionManager, System.Int32 _idListaPrecios)
		{
			int count = -1;
			return GetByIdListaPrecios(transactionManager, _idListaPrecios, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER key.
		///		FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idListaPrecios"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdListaPrecios(TransactionManager transactionManager, System.Int32 _idListaPrecios, int start, int pageLength)
		{
			int count = -1;
			return GetByIdListaPrecios(transactionManager, _idListaPrecios, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER key.
		///		fkPatPkitPatListaPreciosTaller Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idListaPrecios"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdListaPrecios(System.Int32 _idListaPrecios, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdListaPrecios(null, _idListaPrecios, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER key.
		///		fkPatPkitPatListaPreciosTaller Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idListaPrecios"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public TList<PatKit> GetByIdListaPrecios(System.Int32 _idListaPrecios, int start, int pageLength,out int count)
		{
			return GetByIdListaPrecios(null, _idListaPrecios, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER key.
		///		FK_PAT_PKIT_PAT_LISTA_PRECIOS_TALLER Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idListaPrecios"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatKit objects.</returns>
		public abstract TList<PatKit> GetByIdListaPrecios(TransactionManager transactionManager, System.Int32 _idListaPrecios, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override PAT.Entities.PatKit Get(TransactionManager transactionManager, PAT.Entities.PatKitKey key, int start, int pageLength)
		{
			return GetByIdKit(transactionManager, key.IdKit, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_PAT_PKIT index.
		/// </summary>
		/// <param name="_idKit"></param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatKit"/> class.</returns>
		public PAT.Entities.PatKit GetByIdKit(System.Int32 _idKit)
		{
			int count = -1;
			return GetByIdKit(null,_idKit, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_PKIT index.
		/// </summary>
		/// <param name="_idKit"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatKit"/> class.</returns>
		public PAT.Entities.PatKit GetByIdKit(System.Int32 _idKit, int start, int pageLength)
		{
			int count = -1;
			return GetByIdKit(null, _idKit, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_PKIT index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idKit"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatKit"/> class.</returns>
		public PAT.Entities.PatKit GetByIdKit(TransactionManager transactionManager, System.Int32 _idKit)
		{
			int count = -1;
			return GetByIdKit(transactionManager, _idKit, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_PKIT index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idKit"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatKit"/> class.</returns>
		public PAT.Entities.PatKit GetByIdKit(TransactionManager transactionManager, System.Int32 _idKit, int start, int pageLength)
		{
			int count = -1;
			return GetByIdKit(transactionManager, _idKit, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_PKIT index.
		/// </summary>
		/// <param name="_idKit"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatKit"/> class.</returns>
		public PAT.Entities.PatKit GetByIdKit(System.Int32 _idKit, int start, int pageLength, out int count)
		{
			return GetByIdKit(null, _idKit, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_PKIT index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idKit"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatKit"/> class.</returns>
		public abstract PAT.Entities.PatKit GetByIdKit(TransactionManager transactionManager, System.Int32 _idKit, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#region CUST_PAT_KIT_ITEM_GetItemsByIdKit 
		
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_ITEM_GetItemsByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet ITEM_GetItemsByIdKit(System.Int32? idKit, System.Int32? idGrupoCatalogo)
		{
			return ITEM_GetItemsByIdKit(null, 0, int.MaxValue , idKit, idGrupoCatalogo);
		}
		
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_ITEM_GetItemsByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet ITEM_GetItemsByIdKit(int start, int pageLength, System.Int32? idKit, System.Int32? idGrupoCatalogo)
		{
			return ITEM_GetItemsByIdKit(null, start, pageLength , idKit, idGrupoCatalogo);
		}
				
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_ITEM_GetItemsByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet ITEM_GetItemsByIdKit(TransactionManager transactionManager, System.Int32? idKit, System.Int32? idGrupoCatalogo)
		{
			return ITEM_GetItemsByIdKit(transactionManager, 0, int.MaxValue , idKit, idGrupoCatalogo);
		}
		
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_ITEM_GetItemsByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet ITEM_GetItemsByIdKit(TransactionManager transactionManager, int start, int pageLength , System.Int32? idKit, System.Int32? idGrupoCatalogo);
		
		#endregion
		
		#region CUST_PAT_KIT_OPERACION_GetOperacionesByIdKit 
		
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_OPERACION_GetOperacionesByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet OPERACION_GetOperacionesByIdKit(System.Int32? idKit, System.Int32? idGrupoCatalogo)
		{
			return OPERACION_GetOperacionesByIdKit(null, 0, int.MaxValue , idKit, idGrupoCatalogo);
		}
		
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_OPERACION_GetOperacionesByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet OPERACION_GetOperacionesByIdKit(int start, int pageLength, System.Int32? idKit, System.Int32? idGrupoCatalogo)
		{
			return OPERACION_GetOperacionesByIdKit(null, start, pageLength , idKit, idGrupoCatalogo);
		}
				
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_OPERACION_GetOperacionesByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet OPERACION_GetOperacionesByIdKit(TransactionManager transactionManager, System.Int32? idKit, System.Int32? idGrupoCatalogo)
		{
			return OPERACION_GetOperacionesByIdKit(transactionManager, 0, int.MaxValue , idKit, idGrupoCatalogo);
		}
		
		/// <summary>
		///	This method wrap the 'CUST_PAT_KIT_OPERACION_GetOperacionesByIdKit' stored procedure. 
		/// </summary>
		/// <param name="idKit"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idGrupoCatalogo"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet OPERACION_GetOperacionesByIdKit(TransactionManager transactionManager, int start, int pageLength , System.Int32? idKit, System.Int32? idGrupoCatalogo);
		
		#endregion
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;PatKit&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;PatKit&gt;"/></returns>
		public static TList<PatKit> Fill(IDataReader reader, TList<PatKit> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				PAT.Entities.PatKit c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("PatKit")
					.Append("|").Append((System.Int32)reader[((int)PatKitColumn.IdKit - 1)]).ToString();
					c = EntityManager.LocateOrCreate<PatKit>(
					key.ToString(), // EntityTrackingKey
					"PatKit",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new PAT.Entities.PatKit();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.IdKit = (System.Int32)reader[((int)PatKitColumn.IdKit - 1)];
					c.DescripcionKit = (System.String)reader[((int)PatKitColumn.DescripcionKit - 1)];
					c.IdGrupoCatalogo = (System.Int16)reader[((int)PatKitColumn.IdGrupoCatalogo - 1)];
					c.IdListaPrecios = (System.Int32)reader[((int)PatKitColumn.IdListaPrecios - 1)];
					c.Activo = (System.Boolean)reader[((int)PatKitColumn.Activo - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatKit"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatKit"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, PAT.Entities.PatKit entity)
		{
			if (!reader.Read()) return;
			
			entity.IdKit = (System.Int32)reader[((int)PatKitColumn.IdKit - 1)];
			entity.DescripcionKit = (System.String)reader[((int)PatKitColumn.DescripcionKit - 1)];
			entity.IdGrupoCatalogo = (System.Int16)reader[((int)PatKitColumn.IdGrupoCatalogo - 1)];
			entity.IdListaPrecios = (System.Int32)reader[((int)PatKitColumn.IdListaPrecios - 1)];
			entity.Activo = (System.Boolean)reader[((int)PatKitColumn.Activo - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatKit"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatKit"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, PAT.Entities.PatKit entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IdKit = (System.Int32)dataRow["ID_KIT"];
			entity.DescripcionKit = (System.String)dataRow["DESCRIPCION_KIT"];
			entity.IdGrupoCatalogo = (System.Int16)dataRow["ID_GRUPO_CATALOGO"];
			entity.IdListaPrecios = (System.Int32)dataRow["ID_LISTA_PRECIOS"];
			entity.Activo = (System.Boolean)dataRow["ACTIVO"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatKit"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">PAT.Entities.PatKit Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, PAT.Entities.PatKit entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region IdGrupoCatalogoSource	
			if (CanDeepLoad(entity, "PatGrupoCatalogo|IdGrupoCatalogoSource", deepLoadType, innerList) 
				&& entity.IdGrupoCatalogoSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdGrupoCatalogo;
				PatGrupoCatalogo tmpEntity = EntityManager.LocateEntity<PatGrupoCatalogo>(EntityLocator.ConstructKeyFromPkItems(typeof(PatGrupoCatalogo), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdGrupoCatalogoSource = tmpEntity;
				else
					entity.IdGrupoCatalogoSource = DataRepository.PatGrupoCatalogoProvider.GetByIdGrupoCatalogo(transactionManager, entity.IdGrupoCatalogo);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdGrupoCatalogoSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdGrupoCatalogoSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatGrupoCatalogoProvider.DeepLoad(transactionManager, entity.IdGrupoCatalogoSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdGrupoCatalogoSource

			#region IdListaPreciosSource	
			if (CanDeepLoad(entity, "PatListaPreciosTaller|IdListaPreciosSource", deepLoadType, innerList) 
				&& entity.IdListaPreciosSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdListaPrecios;
				PatListaPreciosTaller tmpEntity = EntityManager.LocateEntity<PatListaPreciosTaller>(EntityLocator.ConstructKeyFromPkItems(typeof(PatListaPreciosTaller), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdListaPreciosSource = tmpEntity;
				else
					entity.IdListaPreciosSource = DataRepository.PatListaPreciosTallerProvider.GetByIdListaPrecios(transactionManager, entity.IdListaPrecios);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdListaPreciosSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdListaPreciosSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatListaPreciosTallerProvider.DeepLoad(transactionManager, entity.IdListaPreciosSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdListaPreciosSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByIdKit methods when available
			
			#region IdItemInventarioPatItemInventarioCollection_From_PatKitItem
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatItemInventario>|IdItemInventarioPatItemInventarioCollection_From_PatKitItem", deepLoadType, innerList))
			{
				entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem = DataRepository.PatItemInventarioProvider.GetByIdKitFromPatKitItem(transactionManager, entity.IdKit);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdItemInventarioPatItemInventarioCollection_From_PatKitItem' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem != null)
				{
					deepHandles.Add("IdItemInventarioPatItemInventarioCollection_From_PatKitItem",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatItemInventario >) DataRepository.PatItemInventarioProvider.DeepLoad,
						new object[] { transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region PatKitOperacionCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatKitOperacion>|PatKitOperacionCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatKitOperacionCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatKitOperacionCollection = DataRepository.PatKitOperacionProvider.GetByIdKit(transactionManager, entity.IdKit);

				if (deep && entity.PatKitOperacionCollection.Count > 0)
				{
					deepHandles.Add("PatKitOperacionCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatKitOperacion>) DataRepository.PatKitOperacionProvider.DeepLoad,
						new object[] { transactionManager, entity.PatKitOperacionCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PatKitItemCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatKitItem>|PatKitItemCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatKitItemCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatKitItemCollection = DataRepository.PatKitItemProvider.GetByIdKit(transactionManager, entity.IdKit);

				if (deep && entity.PatKitItemCollection.Count > 0)
				{
					deepHandles.Add("PatKitItemCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatKitItem>) DataRepository.PatKitItemProvider.DeepLoad,
						new object[] { transactionManager, entity.PatKitItemCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PatOrdenTrabajoKitCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatOrdenTrabajoKit>|PatOrdenTrabajoKitCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatOrdenTrabajoKitCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatOrdenTrabajoKitCollection = DataRepository.PatOrdenTrabajoKitProvider.GetByIdKit(transactionManager, entity.IdKit);

				if (deep && entity.PatOrdenTrabajoKitCollection.Count > 0)
				{
					deepHandles.Add("PatOrdenTrabajoKitCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatOrdenTrabajoKit>) DataRepository.PatOrdenTrabajoKitProvider.DeepLoad,
						new object[] { transactionManager, entity.PatOrdenTrabajoKitCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PatCitaTallerCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatCitaTaller>|PatCitaTallerCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatCitaTallerCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatCitaTallerCollection = DataRepository.PatCitaTallerProvider.GetByIdKit(transactionManager, entity.IdKit);

				if (deep && entity.PatCitaTallerCollection.Count > 0)
				{
					deepHandles.Add("PatCitaTallerCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatCitaTaller>) DataRepository.PatCitaTallerProvider.DeepLoad,
						new object[] { transactionManager, entity.PatCitaTallerCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PatMantenimientoProgramadoCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatMantenimientoProgramado>|PatMantenimientoProgramadoCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatMantenimientoProgramadoCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatMantenimientoProgramadoCollection = DataRepository.PatMantenimientoProgramadoProvider.GetByIdKit(transactionManager, entity.IdKit);

				if (deep && entity.PatMantenimientoProgramadoCollection.Count > 0)
				{
					deepHandles.Add("PatMantenimientoProgramadoCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatMantenimientoProgramado>) DataRepository.PatMantenimientoProgramadoProvider.DeepLoad,
						new object[] { transactionManager, entity.PatMantenimientoProgramadoCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatGrupoCatalogo>|IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado", deepLoadType, innerList))
			{
				entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado = DataRepository.PatGrupoCatalogoProvider.GetByIdKitFromPatMantenimientoProgramado(transactionManager, entity.IdKit);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado != null)
				{
					deepHandles.Add("IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatGrupoCatalogo >) DataRepository.PatGrupoCatalogoProvider.DeepLoad,
						new object[] { transactionManager, entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatOrdenTrabajo>|IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit", deepLoadType, innerList))
			{
				entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit = DataRepository.PatOrdenTrabajoProvider.GetByIdKitFromPatOrdenTrabajoKit(transactionManager, entity.IdKit);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit != null)
				{
					deepHandles.Add("IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatOrdenTrabajo >) DataRepository.PatOrdenTrabajoProvider.DeepLoad,
						new object[] { transactionManager, entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region IdOperacionPatTemparioCollection_From_PatKitOperacion
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatTempario>|IdOperacionPatTemparioCollection_From_PatKitOperacion", deepLoadType, innerList))
			{
				entity.IdOperacionPatTemparioCollection_From_PatKitOperacion = DataRepository.PatTemparioProvider.GetByIdKitFromPatKitOperacion(transactionManager, entity.IdKit);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdOperacionPatTemparioCollection_From_PatKitOperacion' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdOperacionPatTemparioCollection_From_PatKitOperacion != null)
				{
					deepHandles.Add("IdOperacionPatTemparioCollection_From_PatKitOperacion",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatTempario >) DataRepository.PatTemparioProvider.DeepLoad,
						new object[] { transactionManager, entity.IdOperacionPatTemparioCollection_From_PatKitOperacion, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the PAT.Entities.PatKit object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">PAT.Entities.PatKit instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">PAT.Entities.PatKit Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, PAT.Entities.PatKit entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region IdGrupoCatalogoSource
			if (CanDeepSave(entity, "PatGrupoCatalogo|IdGrupoCatalogoSource", deepSaveType, innerList) 
				&& entity.IdGrupoCatalogoSource != null)
			{
				DataRepository.PatGrupoCatalogoProvider.Save(transactionManager, entity.IdGrupoCatalogoSource);
				entity.IdGrupoCatalogo = entity.IdGrupoCatalogoSource.IdGrupoCatalogo;
			}
			#endregion 
			
			#region IdListaPreciosSource
			if (CanDeepSave(entity, "PatListaPreciosTaller|IdListaPreciosSource", deepSaveType, innerList) 
				&& entity.IdListaPreciosSource != null)
			{
				DataRepository.PatListaPreciosTallerProvider.Save(transactionManager, entity.IdListaPreciosSource);
				entity.IdListaPrecios = entity.IdListaPreciosSource.IdListaPrecios;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();

			#region IdItemInventarioPatItemInventarioCollection_From_PatKitItem>
			if (CanDeepSave(entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem, "List<PatItemInventario>|IdItemInventarioPatItemInventarioCollection_From_PatKitItem", deepSaveType, innerList))
			{
				if (entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem.Count > 0 || entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem.DeletedItems.Count > 0)
				{
					DataRepository.PatItemInventarioProvider.Save(transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem); 
					deepHandles.Add("IdItemInventarioPatItemInventarioCollection_From_PatKitItem",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatItemInventario>) DataRepository.PatItemInventarioProvider.DeepSave,
						new object[] { transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatKitItem, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado>
			if (CanDeepSave(entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado, "List<PatGrupoCatalogo>|IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado", deepSaveType, innerList))
			{
				if (entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado.Count > 0 || entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado.DeletedItems.Count > 0)
				{
					DataRepository.PatGrupoCatalogoProvider.Save(transactionManager, entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado); 
					deepHandles.Add("IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatGrupoCatalogo>) DataRepository.PatGrupoCatalogoProvider.DeepSave,
						new object[] { transactionManager, entity.IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit>
			if (CanDeepSave(entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit, "List<PatOrdenTrabajo>|IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit", deepSaveType, innerList))
			{
				if (entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit.Count > 0 || entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit.DeletedItems.Count > 0)
				{
					DataRepository.PatOrdenTrabajoProvider.Save(transactionManager, entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit); 
					deepHandles.Add("IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatOrdenTrabajo>) DataRepository.PatOrdenTrabajoProvider.DeepSave,
						new object[] { transactionManager, entity.IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region IdOperacionPatTemparioCollection_From_PatKitOperacion>
			if (CanDeepSave(entity.IdOperacionPatTemparioCollection_From_PatKitOperacion, "List<PatTempario>|IdOperacionPatTemparioCollection_From_PatKitOperacion", deepSaveType, innerList))
			{
				if (entity.IdOperacionPatTemparioCollection_From_PatKitOperacion.Count > 0 || entity.IdOperacionPatTemparioCollection_From_PatKitOperacion.DeletedItems.Count > 0)
				{
					DataRepository.PatTemparioProvider.Save(transactionManager, entity.IdOperacionPatTemparioCollection_From_PatKitOperacion); 
					deepHandles.Add("IdOperacionPatTemparioCollection_From_PatKitOperacion",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatTempario>) DataRepository.PatTemparioProvider.DeepSave,
						new object[] { transactionManager, entity.IdOperacionPatTemparioCollection_From_PatKitOperacion, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 
	
			#region List<PatKitOperacion>
				if (CanDeepSave(entity.PatKitOperacionCollection, "List<PatKitOperacion>|PatKitOperacionCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatKitOperacion child in entity.PatKitOperacionCollection)
					{
						if(child.IdKitSource != null)
						{
								child.IdKit = child.IdKitSource.IdKit;
						}

						if(child.IdOperacionSource != null)
						{
								child.IdOperacion = child.IdOperacionSource.IdOperacion;
						}

					}

					if (entity.PatKitOperacionCollection.Count > 0 || entity.PatKitOperacionCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatKitOperacionProvider.Save(transactionManager, entity.PatKitOperacionCollection);
						
						deepHandles.Add("PatKitOperacionCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatKitOperacion >) DataRepository.PatKitOperacionProvider.DeepSave,
							new object[] { transactionManager, entity.PatKitOperacionCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatKitItem>
				if (CanDeepSave(entity.PatKitItemCollection, "List<PatKitItem>|PatKitItemCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatKitItem child in entity.PatKitItemCollection)
					{
						if(child.IdKitSource != null)
						{
								child.IdKit = child.IdKitSource.IdKit;
						}

						if(child.IdItemInventarioSource != null)
						{
								child.IdItemInventario = child.IdItemInventarioSource.IdItemInventario;
						}

					}

					if (entity.PatKitItemCollection.Count > 0 || entity.PatKitItemCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatKitItemProvider.Save(transactionManager, entity.PatKitItemCollection);
						
						deepHandles.Add("PatKitItemCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatKitItem >) DataRepository.PatKitItemProvider.DeepSave,
							new object[] { transactionManager, entity.PatKitItemCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatOrdenTrabajoKit>
				if (CanDeepSave(entity.PatOrdenTrabajoKitCollection, "List<PatOrdenTrabajoKit>|PatOrdenTrabajoKitCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatOrdenTrabajoKit child in entity.PatOrdenTrabajoKitCollection)
					{
						if(child.IdKitSource != null)
						{
								child.IdKit = child.IdKitSource.IdKit;
						}

						if(child.IdDocumentoNumeroOrdenSource != null)
						{
								child.IdDocumento = child.IdDocumentoNumeroOrdenSource.IdDocumento;
								child.NumeroOrden = child.IdDocumentoNumeroOrdenSource.NumeroOrden;
						}

					}

					if (entity.PatOrdenTrabajoKitCollection.Count > 0 || entity.PatOrdenTrabajoKitCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatOrdenTrabajoKitProvider.Save(transactionManager, entity.PatOrdenTrabajoKitCollection);
						
						deepHandles.Add("PatOrdenTrabajoKitCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatOrdenTrabajoKit >) DataRepository.PatOrdenTrabajoKitProvider.DeepSave,
							new object[] { transactionManager, entity.PatOrdenTrabajoKitCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatCitaTaller>
				if (CanDeepSave(entity.PatCitaTallerCollection, "List<PatCitaTaller>|PatCitaTallerCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatCitaTaller child in entity.PatCitaTallerCollection)
					{
						if(child.IdKitSource != null)
						{
							child.IdKit = child.IdKitSource.IdKit;
						}
						else
						{
							child.IdKit = entity.IdKit;
						}

					}

					if (entity.PatCitaTallerCollection.Count > 0 || entity.PatCitaTallerCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatCitaTallerProvider.Save(transactionManager, entity.PatCitaTallerCollection);
						
						deepHandles.Add("PatCitaTallerCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatCitaTaller >) DataRepository.PatCitaTallerProvider.DeepSave,
							new object[] { transactionManager, entity.PatCitaTallerCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatMantenimientoProgramado>
				if (CanDeepSave(entity.PatMantenimientoProgramadoCollection, "List<PatMantenimientoProgramado>|PatMantenimientoProgramadoCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatMantenimientoProgramado child in entity.PatMantenimientoProgramadoCollection)
					{
						if(child.IdKitSource != null)
						{
								child.IdKit = child.IdKitSource.IdKit;
						}

						if(child.IdGrupoCatalogoSource != null)
						{
								child.IdGrupoCatalogo = child.IdGrupoCatalogoSource.IdGrupoCatalogo;
						}

					}

					if (entity.PatMantenimientoProgramadoCollection.Count > 0 || entity.PatMantenimientoProgramadoCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatMantenimientoProgramadoProvider.Save(transactionManager, entity.PatMantenimientoProgramadoCollection);
						
						deepHandles.Add("PatMantenimientoProgramadoCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatMantenimientoProgramado >) DataRepository.PatMantenimientoProgramadoProvider.DeepSave,
							new object[] { transactionManager, entity.PatMantenimientoProgramadoCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region PatKitChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>PAT.Entities.PatKit</c>
	///</summary>
	public enum PatKitChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>PatGrupoCatalogo</c> at IdGrupoCatalogoSource
		///</summary>
		[ChildEntityType(typeof(PatGrupoCatalogo))]
		PatGrupoCatalogo,
			
		///<summary>
		/// Composite Property for <c>PatListaPreciosTaller</c> at IdListaPreciosSource
		///</summary>
		[ChildEntityType(typeof(PatListaPreciosTaller))]
		PatListaPreciosTaller,
	
		///<summary>
		/// Collection of <c>PatKit</c> as ManyToMany for PatItemInventarioCollection_From_PatKitItem
		///</summary>
		[ChildEntityType(typeof(TList<PatItemInventario>))]
		IdItemInventarioPatItemInventarioCollection_From_PatKitItem,

		///<summary>
		/// Collection of <c>PatKit</c> as OneToMany for PatKitOperacionCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatKitOperacion>))]
		PatKitOperacionCollection,

		///<summary>
		/// Collection of <c>PatKit</c> as OneToMany for PatKitItemCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatKitItem>))]
		PatKitItemCollection,

		///<summary>
		/// Collection of <c>PatKit</c> as OneToMany for PatOrdenTrabajoKitCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatOrdenTrabajoKit>))]
		PatOrdenTrabajoKitCollection,

		///<summary>
		/// Collection of <c>PatKit</c> as OneToMany for PatCitaTallerCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatCitaTaller>))]
		PatCitaTallerCollection,

		///<summary>
		/// Collection of <c>PatKit</c> as OneToMany for PatMantenimientoProgramadoCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatMantenimientoProgramado>))]
		PatMantenimientoProgramadoCollection,

		///<summary>
		/// Collection of <c>PatKit</c> as ManyToMany for PatGrupoCatalogoCollection_From_PatMantenimientoProgramado
		///</summary>
		[ChildEntityType(typeof(TList<PatGrupoCatalogo>))]
		IdGrupoCatalogoPatGrupoCatalogoCollection_From_PatMantenimientoProgramado,

		///<summary>
		/// Collection of <c>PatKit</c> as ManyToMany for PatOrdenTrabajoCollection_From_PatOrdenTrabajoKit
		///</summary>
		[ChildEntityType(typeof(TList<PatOrdenTrabajo>))]
		IdDocumentoNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoKit,

		///<summary>
		/// Collection of <c>PatKit</c> as ManyToMany for PatTemparioCollection_From_PatKitOperacion
		///</summary>
		[ChildEntityType(typeof(TList<PatTempario>))]
		IdOperacionPatTemparioCollection_From_PatKitOperacion,
	}
	
	#endregion PatKitChildEntityTypes
	
	#region PatKitFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;PatKitColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatKit"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatKitFilterBuilder : SqlFilterBuilder<PatKitColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatKitFilterBuilder class.
		/// </summary>
		public PatKitFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatKitFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatKitFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatKitFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatKitFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatKitFilterBuilder
	
	#region PatKitParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;PatKitColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatKit"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatKitParameterBuilder : ParameterizedSqlFilterBuilder<PatKitColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatKitParameterBuilder class.
		/// </summary>
		public PatKitParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatKitParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatKitParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatKitParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatKitParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatKitParameterBuilder
	
	#region PatKitSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;PatKitColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatKit"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class PatKitSortBuilder : SqlSortBuilder<PatKitColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatKitSqlSortBuilder class.
		/// </summary>
		public PatKitSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion PatKitSortBuilder
	
} // end namespace
